@extends('Backstage.Layouts.layout')

@section('content')
    <style>
        .layui-form-label{width: 200px}
    </style>
    <div class="site-text site-block">
        <form class="layui-form layui-form-pane" action="">
            <input id="admin_note_id" name="id" type="hidden" value="{{$data->admin_note_id}}">
            {{csrf_field()}}
            <div class="layui-form-item">
                <label class="layui-form-label">节点名称</label>
                <div class="layui-input-block">
                    <input value="{{$data->admin_note_name}}" type="text" name="param[admin_note_name]" lay-verify="required" lay-vertype="tips"  autocomplete="off" placeholder="请输入" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">节点备注</label>
                <div class="layui-input-block">
                    <input value="{{$data->admin_note_zh_name}}"  type="text" name="param[admin_note_zh_name]" lay-verify="required" lay-vertype="tips"  autocomplete="off" placeholder="请输入" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">换行</label>
                <div class="layui-input-block">
                    <input type="checkbox" name="param[admin_note_default]" @if($data->admin_note_default) checked="" @endif value="1" lay-skin="switch" lay-text="是|否"  lay-verify="required" lay-vertype="tips"  autocomplete="off">

                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">分割线</label>
                <div class="layui-input-block">
                    <input type="checkbox" name="param[admin_box]" @if($data->admin_box) checked="" @endif value="1" lay-skin="switch" lay-text="是|否"  lay-verify="required" lay-vertype="tips"  autocomplete="off">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">路由name</label>
                <div class="layui-input-block">
                    <input value="{{$data->admin_note_controller}}"  type="text" name="param[admin_note_controller]" lay-verify="required" lay-vertype="tips"  autocomplete="off" placeholder="请输入" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">父级name</label>
                <div class="layui-input-block">
                    <input value="{{$data->admin_note_action}}"  type="text" name="param[admin_note_action]" lay-verify="required" lay-vertype="tips"  autocomplete="off" placeholder="请输入" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">(如果是父级,该字段存它下面所有的子集name英文,号分割。如果是子集,该字段存他的父级name)</div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">管理员可见</label>
                <div class="layui-input-block">
                    <input type="checkbox" name="param[admin_admin_show]" @if($data->admin_admin_show) checked="" @endif value="1" lay-skin="switch" lay-text="是|否"  lay-verify="required" lay-vertype="tips"  autocomplete="off">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">父级ID</label>
                <div class="layui-input-block">
                    <input value="{{$data->admin_note_parent_id}}"  type="text" name="param[admin_note_parent_id]" lay-verify="required" lay-vertype="tips"  autocomplete="off" placeholder="请输入" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">排序编号</label>
                <div class="layui-input-block">
                    <input value="{{$data->admin_note_sort}}"  type="text" name="param[admin_note_sort]" lay-verify="required" lay-vertype="tips"  autocomplete="off" placeholder="请输入" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">导航显示</label>
                <div class="layui-input-block">
                    <input type="checkbox" name="param[admin_note_show]" @if($data->admin_note_show) checked="" @endif value="1" lay-skin="switch" lay-text="是|否"  lay-verify="required" lay-vertype="tips"  autocomplete="off">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">拥有子集</label>
                <div class="layui-input-block">
                    <input type="checkbox" name="param[admin_has_subset]" @if($data->admin_has_subset) checked="" @endif value="1" lay-skin="switch" lay-text="是|否" lay-verify="required" lay-vertype="tips"  autocomplete="off">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="form">立即提交</button>
                </div>
            </div>
        </form>
    </div>

@stop

@section('script')

    <script>
        layui.use(['upload','form'], function(){
            var form = layui.form;
            //监听提交
            form.on('submit(form)', function(data){

                var $this = $(data.elem);
                $this.attr('disabled', 'disabled');
                layer.msg('数据请求中···', {
                    icon: 16
                    ,shade: 0.01
                },0);
                $.ajax({
                    url: '{{URL::route('admin_note_save')}}',
                    data: data.field,
                    type: 'post',
                    cache: false,
                    dataType: 'json',
                    success: function (data) {
                        layer.closeAll();
                        if (data['status'] == 1) {

                            layer.msg(data['msg'], { icon: 1});
                            location.replace('{{URL::route('admin_note_index')}}');

                        } else {
                            layer.msg(data['msg'], { icon: 2});
                            $this.attr("disabled",false);
                        }

                    },
                    error: function () {
                        layer.closeAll();
                        layer.msg('请求发生错误');
                        $this.attr("disabled",false);
                    }
                });

                return false;

            });
        });



    </script>
@stop

